<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    .box {
      width: 100px;
      height: 100px;
      background: palegreen;
      position: fixed;

      text-align: center;
      line-height: 100px;
      font-size: 15px;
    }
  </style>
</head>
<body>
  <button>动起来</button>
  <div class="box"></div>
</body>
</html>
<script src="./move.js"></script>
<script>
// 英文：
  // distance  距离
  // step 步幅
  // unit 单位

const box = document.querySelector('.box');

// 案例：从上向下，移动 400 像素   +  从左往右 移动600像素

document.querySelector('button')
  .addEventListener('click', e => {
    // console.log('click');
    move(
      box, 
      {
      top: 400,
      left: {
        init: 100,
        targetDistance: 500,
        step: 5
      },
      'border-radius': {
        step: 1,
        unit: '%',
        targetDistance: 50
      },
      opacity: {
        step: 0.01,
        init: 0.1,
        targetDistance: 1,
        unit: ''
      }
    },
    // callback ->  动画结束 执行该回调
    () => {
      box.innerText = '结束啦！';
    }
    )
  })




</script>